home *** CD-ROM | disk | FTP | other *** search
/ Champak 132 (Alt) / Vol 132.iso / games / 3d_hyper / 3d_hyper.dcr / Scripts_7_countdownFrame.ls < prev    next >
Encoding:
Text File  |  2011-06-09  |  2.1 KB  |  78 lines

  1. property pLastFrameTime, pBeginFrame, pCurrTimer, pCameraOverlay
  2. global gCamera, gCar, gWorld, gRacers, gSparkLocs, gTransFormat, gSolidFormat, gSpriteScale
  3.  
  4. on beginSprite me
  5.   pLastFrameTime = the milliSeconds
  6.   pCurrTimer = -1
  7.   gCar = gWorld.model("carModel_1")
  8. end
  9.  
  10. on exitFrame
  11.   if voidp(pBeginFrame) then
  12.     pBeginFrame = the milliSeconds
  13.   end if
  14.   totalTime = the milliSeconds - pBeginFrame
  15.   checkForExit()
  16.   if totalTime < 1000 then
  17.     if pCurrTimer <> 3 then
  18.       showTimer(3)
  19.       pCurrTimer = 3
  20.       sound(2).play(member("boop"))
  21.     end if
  22.   else
  23.     if totalTime < 2000 then
  24.       if pCurrTimer <> 2 then
  25.         showTimer(2)
  26.         gWorld.deleteTexture("countdown3")
  27.         pCurrTimer = 2
  28.         sound(2).play(member("boop"))
  29.       end if
  30.     else
  31.       if totalTime < 3000 then
  32.         if pCurrTimer <> 1 then
  33.           showTimer(1)
  34.           gWorld.deleteTexture("countdown2")
  35.           pCurrTimer = 1
  36.           sound(2).play(member("boop"))
  37.         end if
  38.       else
  39.         gCamera.removeOverlay(pCameraOverlay)
  40.         gWorld.deleteTexture("countdown1")
  41.         pCurrTimer = 0
  42.         sound(2).play(member("beep"))
  43.         go("Race")
  44.       end if
  45.     end if
  46.   end if
  47.   updateSky()
  48.   go(the frame)
  49. end
  50.  
  51. on showTimer theNum
  52.   theTex = gWorld.newTexture("countdown" & theNum, #fromCastMember, member("countdown" & theNum))
  53.   theTex.renderFormat = gTransFormat
  54.   if voidp(pCameraOverlay) then
  55.     pCameraOverlay = gCamera.overlay.count + 1
  56.     gCamera.addOverlay(theTex, point(336, 186) * gSpriteScale, 0)
  57.     gCamera.overlay[pCameraOverlay].scale = gSpriteScale
  58.   else
  59.     gCamera.overlay[pCameraOverlay].source = theTex
  60.   end if
  61. end
  62.  
  63. on prepareFrame me
  64.   timeElapsed = the milliSeconds - pLastFrameTime
  65.   repeat with i = 1 to gRacers.count
  66.     gRacers[i].updateCarFloat()
  67.     currMo = gRacers[i].pHavokCar.linearMomentum
  68.     currMo.z = 0.0
  69.     currVel = gRacers[i].pHavokCar.linearVelocity
  70.     currVel.z = 0.0
  71.     gRacers[i].pHavokCar.linearMomentum = currMo
  72.     gRacers[i].pHavokCar.linearVelocity = currVel
  73.   end repeat
  74.   updateCamera()
  75.   updateSpeedometer()
  76.   pLastFrameTime = the milliSeconds
  77. end
  78.